package com.suoluo.zenadmin.vo.hotel;

import java.util.Collections;
import java.util.List;

import com.suoluo.zenadmin.common.GeometryUtil;

public class HotelAroundVO {

	private AroundNodeVO center;
	
	private List<AroundCategoryVO> categoryList;
	
	private AroundCategoryVO curCategory;
	
	private boolean allCategory;
	
	private List<AroundNodeVO> nodes;

	public List<AroundNodeVO> getNodes() {
		return nodes;
	}

	public void setNodes(List<AroundNodeVO> nodes) {
		this.nodes = nodes;
	}

	public AroundNodeVO getCenter() {
		return center;
	}

	public void setCenter(AroundNodeVO center) {
		this.center = center;
	}
	
	public AroundCategoryVO getCurCategory() {
		return curCategory;
	}

	public void setCurCategory(AroundCategoryVO curCategory) {
		this.curCategory = curCategory;
	}

	public List<AroundCategoryVO> getCategoryList() {
		return categoryList;
	}

	public void setCategoryList(List<AroundCategoryVO> categoryList) {
		this.categoryList = categoryList;
	}

	public boolean isAllCategory() {
		return allCategory;
	}

	public void setAllCategory(boolean allCategory) {
		this.allCategory = allCategory;
	}



//	private static double EARTH_R = 6378.137;
//	
//	public static double degreesToRadians(double deg){
//		return deg * (Math.PI / 180);
//	}
//	
//	
//	
//	public static double radiansToDegrees(double rad){
//		return rad / (Math.PI / 180);
//	}
//	
//	public static double calcDistance(double lat1,double lng1,double lat2,double lng2){
//		double f = degreesToRadians((lat1 + lat2) /2);
//		double g = degreesToRadians((lat1 - lat2)/2);
//		double l = degreesToRadians((lng1 - lng2)/2);
//		double sg = Math.sin(g);
//		double sl = Math.sin(l);
//		double sf = Math.sin(f);
//		
//		double s,c,w,r,d,h1,h2;
//		double a = EARTH_R;
//		double fl = 1/298.257;
//		sg = sg*sg;
//		sl = sl*sl;
//		sf = sf*sf;
//
//		s = sg*(1-sl) + (1-sf)*sl;
//		c = (1-sg)*(1-sl) + sf*sl;
//
//		w = Math.atan(Math.sqrt(s/c));
//		r = Math.sqrt(s*c)/w;
//		d = 2*w*a;
//		h1 = (3*r -1)/2/c;
//		h2 = (3*r +1)/2/s;
//		
//		double value =  d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
//		//四舍五入，保留3位精度
//		return round(value,3);
//	}
//	
////	private double round(double value )
////
////	Distance.calcDistance = function (lat1,lng1,lat2,lng2){
////		var f = this.degreesToRadians((lat1 + lat2) /2)
////		var g = this.degreesToRadians((lat1 - lat2)/2);
////		var l = this.degreesToRadians((lng1 - lng2)/2);
////		var sg = Math.sin(g);
////		var sl = Math.sin(l);
////		var sf = Math.sin(f);
////		
////		var s,c,w,r,d,h1,h2;
////		var a = this.EARTH_R;
////		var fl = 1/298.257;
////		sg = sg*sg;
////		sl = sl*sl;
////		sf = sf*sf;
////
////		s = sg*(1-sl) + (1-sf)*sl;
////		c = (1-sg)*(1-sl) + sf*sl;
////
////		w = Math.atan(Math.sqrt(s/c));
////		r = Math.sqrt(s*c)/w;
////		d = 2*w*a;
////		h1 = (3*r -1)/2/c;
////		h2 = (3*r +1)/2/s;
////		
////		double value =  d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
////		//四舍五入，保留3位精度
////		return round(value,3);
////	}
//	public static double round(double v, double p) {
//		double t = 1.0;
//		for (; p > 0; t *= 10, p--);
//		for (; p < 0; t /= 10, p++);
//		return Math.round(v * t) / t;
//	}
//	
	public void calcDistanceAndSort() {
		
//		DistanceComparator comparator =new DistanceComparator();
		for (AroundCategoryVO category : this.categoryList){
			List<AroundNodeVO> nodeList = category.getNodeList();
			for (AroundNodeVO node : category.getNodeList()){
				double distance = GeometryUtil.calcDistance(center,node);
				node.setDistance(distance);
			}
			//每个类别下的按距离排序
			Collections.sort(nodeList);
		}
		//排序类别
		Collections.sort(this.categoryList);
	}
	
//	private static class DistanceComparator implements Comparator<AroundNodeVO>{
//
//		@Override
//		public int compare(AroundNodeVO o1, AroundNodeVO o2) {
//			Double d1 = o1.getDistance();
//			Double d2 = o2.getDistance();
//			return d1.compareTo(d2);
//		}
//		
//	}
	
	public static void main(String []args){
		System.out.println((2.222222+4.222222222)/2);
	}
//	Distance.distance = function (latLng1,latLng2){
//		return this.calcDistance(latLng1.lat(),latLng1.lng(),latLng2.lat(),latLng2.lng());
//	}
//	return Distance;
}
